package gov.kqqzyyy.monkey.orderpad.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;

import com.socks.library.KLog;

import gov.kqqzyyy.monkey.orderpad.ui.NavigationBaseActivity;

public class GPSInfoReceiver extends BroadcastReceiver {

    private final Context mContext;

    public GPSInfoReceiver(Context context) {
        this.mContext = context;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (LocationManager.PROVIDERS_CHANGED_ACTION.equals(action)) {
            KLog.d("APE", "gps changed");
            LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
            boolean gpsOn = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
            if (gpsOn) {
                KLog.d("APE", "gps is on");
                ((NavigationBaseActivity) mContext).setWIFIInfo(null);
            }
        }
    }
}
